package com.sparrow.common.ai.behaviortree.node.impl;

import com.sparrow.common.ai.behaviortree.node.AbstractBehaviorNode;
import com.sparrow.common.ai.behaviortree.node.BehaviorNode;
import com.sparrow.common.ai.behaviortree.task.BehaviorTask;
import com.sparrow.common.ai.behaviortree.task.impl.SequenceTask;

import java.util.List;

/**
 * 逐个执行子节点，直到一个子节点失败。如果所有子节点都成功，整个 Sequence 成功。
 */
public class SequenceNode extends AbstractBehaviorNode {
    private List<BehaviorNode> children;

    public SequenceNode(List<BehaviorNode> children) {
        this.children = children;
    }

    @Override
    public BehaviorTask createTask() {
        return new SequenceTask(this);
    }

    @Override
    public List<BehaviorNode> getChildren() {
        return children;
    }

}
